import { createApp } from 'vue'
import App from './App.vue'
import { createRouter, createWebHistory } from "vue-router";
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const routes = [
  {
  path: '/',
  name: 'Login',
  component: () => import('./views/Login.vue'),
  meta: { hideLayout: true }
  },
  // {
  //   path: '/',
  //   redirect: '/users'
  // },
  {
    path: '/users',
    name: 'UserList',
    component: () => import('./views/Users/UserList.vue'),
  },
  {
    path: '/addUser',
    name: 'UserAdd',
    component: () => import('./views/Users/UserAdd.vue'),
  },
  {
    path: '/editUser/:id',
    name: 'UserEdit',
    component: () => import('./views/Users/UserEdit.vue'),
  },
  {
    path: '/students',
    name: 'StudentList',
    component: () => import('./views/Students/StudentList.vue'),
  },
  {
    path: '/addStudent',
    name: 'StudentAdd',
    component: () => import('./views/Students/StudentAdd.vue'),
  },
  {
    path: '/editStudent/:id',
    name: 'StudentEdit',
    component: () => import('./views/Students/StudentEdit.vue'),
  },
  {
    path: '/dorms',
    name: 'DormList',
    component: () => import('./views/Dorms/DormList.vue'),
  },
  {
    path: '/addDorm',
    name: 'DormAdd',
    component: () => import('./views/Dorms/DormAdd.vue'),
  },
  {
    path: '/editDorm/:id',
    name: 'DormEdit',
    component: () => import('./views/Dorms/DormEdit.vue'),
  },
  {
    path: '/absences',
    name: 'AbsenceList',
    component: () => import('./views/Absences/AbsenceList.vue'),
  },
  {
    path: '/addAbsence',
    name: 'AbsenceAdd',
    component: () => import('./views/Absences/AbsenceAdd.vue'),
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

const app = createApp(App)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(ElementPlus)
app.use(router).mount('#app')